package com.xiaohuihui.springbootes.springbootes.controller;

import com.xiaohuihui.springbootes.springbootes.entity.UserEntity;
import com.xiaohuihui.springbootes.springbootes.service.EsTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private EsTestService esTestService;

    @PostMapping("/save")
    public void save(@RequestBody UserEntity userEntity) {
        esTestService.save(userEntity);
    }

    @PostMapping("/findByUsername")
    public List<UserEntity> findUserByUsername(@RequestParam("username") String username) {
        List<UserEntity> userEntityList = esTestService.findByUsername(username);
        return userEntityList;
    }

    @PostMapping("/findUserBySex")
    public List<UserEntity> findUserBySex(@RequestParam("sex") String sex) {
        List<UserEntity> userEntityList = esTestService.findBySex(sex);
        return userEntityList;
    }


}
